import React from 'react';
import  './newsCom.css';
class NewsCom extends  React.Component{
    constructor(props){
        super(props);
        this.state={
            newsData:this.props.newsData.data
        }
    }
    componentWillMount(){
        console.log('从app组件传过来的新闻数据是：',this.props.newsData.data);
    };
    render(){
        return (
            <div className='newsWrap' >
                <div className='newsContentWrap'>
                    <h5>频道：{this.state.newsData.result.channel}</h5>
                    <ul className='news_ul'>
                        <div className='line_wrap'>
                                <span className='news_line'></span>
                        </div>
                        {
                         this.state.newsData.result.list.map((item,idx)=>{
                            return (
                                <li className='newsItem' key={idx}>
                                    <a target='_blank' href={item.weburl}>
                                        <div className='title_wrap'>
                                            <h6 className='title'>{item.title}</h6>
                                            <span className='news_time'>{item.time}</span>
                                        </div>
                                        <div className='img_wrap'>
                                            <img src={item.pic} alt={item.src}></img>
                                        </div>
                                        
                                    </a>
                                </li>   
                            )
                         })   
                        }

                    </ul>
                </div>
            </div> 
        )
    }
}

export default NewsCom;